package com.cloud.cop.validation;

import java.io.IOException;
import java.util.Properties;

import org.springframework.core.io.support.PropertiesLoaderUtils;
import org.springframework.util.Assert;

/**
 * 基于文件的密钥管理
 * @author mayh
 *
 */
public class FileBaseAppSecretManager implements AppSecretManager {
	
	 private Properties properties;

	 /**
	  * 获得密钥
	  */
	public String getSecret(String appKey) {
		if(properties == null){
            try {
                properties = PropertiesLoaderUtils.loadAllProperties("cop.appSecret.properties");
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        String secret = properties.getProperty(appKey);
		return secret;
	}

}
